﻿@model IEnumerable<Hrm.Core.BlogPost>
@{
    ViewBag.Title = "Blog";
}
<div id="content">
    <section id="topbar">
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    <h1>博客</h1>
                </div>
                <div class="col-md-6 text-right">
                    <ul class="breadcrumb">
                        <li>
                            <a href="@Url.Action("Index")">首页</a>
                        </li>
                        <li class="active">博客</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>
    <section class="blog-list white-bg">
        <div class="container">
            <div class="col-md-8">
                <ul id="blogContent" class=" timeline-icons timeline-advanced timeline-blog-list">
                    @foreach (var item in Model)
                    {
                        <li>
                            <h2 class="timeline-title">
                                <a href="/Home/BlogItem/@item.Id" class="title-link">
                                    @item.Title
                                </a>
                            </h2>
                            <div class="blog-meta timeline-subtitle">
                                <span class="date">
                                    <a href="#">
                                        <i class="fa fa-calendar"></i>
                                        @item.CreateDatetime
                                    </a>
                                </span>
                                <span class="seperator">/</span>
                                <span class="author">
                                    <a href="#">
                                        <i class="fa fa-user"></i>
                                        @item.CreateUserCode
                                    </a>
                                </span>
                                <span class="seperator">/</span>
                                <span class="category">
                                    <a href="#">@item.Type</a>
                                </span>
                                <span class="seperator">/</span>
                                <span class="comments"><a href="#"><i class="fa fa-comments"></i>@item.BlogComments.Count </a></span>
                            </div>
                            <p>@item.Description</p>
                            <hr class="mt30 mb50">
                        </li>
                    }
                </ul>
            </div>
            <div class="sidebar sidebar-right col-md-4">
                @Html.Action("PartViewPopularBlogs")
                @Html.Action("PartViewTagsCloud")

            </div>
        </div>
    </section>
</div>
@section JavascriptSection{
    <script src="~/js/pages/blank.js"></script>
    <script src="~/Scripts/jquery.Bmz.dPage-1.01.1.js"></script>
    <script>
        $(function () {
            $("#blogContent").InitialPage({
                pageSize: 10,
                pageCount: @ViewBag.recordsTotal,
                pageIndex: 2,
                nextPageFunction: function (pageStart, pageSize) {
                    $.ajax({
                        type: "post",
                        url: '@Url.Action("BlogJson")',
                        dataType:"json",
                        data: {
                            start: pageStart,
                            length: pageSize,
                            filter: { Tags: "" }
                        },
                        success: function (result) {
                            result = JSON.parse(result);
                            var data = result.data;
                            var htmlContext = '';
                            for(var index in data)
                                htmlContext += '<li><h2 class="timeline-title"><a href="/Home/BlogItem/' + data[index].Id + '" class="title-link">' + data[index].Title + '</a></h2><div class="blog-meta timeline-subtitle"><span class="date"><a href="#"><i class="fa fa-calendar"></i>'+data[index].CreateDatetime+'</a></span><span class="seperator">/</span><span class="author"><a href="#"><i class="fa fa-user"></i>'+data[index].CreateUserCode+'</a></span><span class="seperator">/</span><span class="category"><a href="#">' + data[index].Type + '</a></span><span class="seperator">/</span><span class="comments"><a href="#"><i class="fa fa-comments"></i>' + data[index].BlogComments.length + '</a></div><p>' + data[index].Description + '</p><hr class="mt30 mb50"></li>';
                            $("#blogContent").append(htmlContext);
                            $.NextPage();
                        }
                    });
                }
            });
        })
    </script>
}
